<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/mytags.jsp"%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<base href="<%=basePath%>">
<%@ include file="/common/easyui.jsp"%>

<script type="text/javascript">
	//菜单json
	var menus = [
	    {"id":"1","pid":"0","name":"顶级菜单","href":"","icon":"icon-nav"}
	    //一级菜单
	    ,{"id":"2","pid":"1","name":"权限管理","href":"","icon":"icon-nav"}
	    ,{"id":"3","pid":"1","name":"自动生成","href":"","icon":"icon-nav"}
	    ,{"id":"4","pid":"1","name":"运行监控","href":"","icon":"icon-nav"}
	    ,{"id":"5","pid":"1","name":"个人博客","href":"","icon":"icon-nav"}
	    ,{"id":"6","pid":"1","name":"CMS","href":"","icon":"icon-nav"}
	    ,{"id":"7","pid":"1","name":"OA","href":"","icon":"icon-nav"}
	    //二级菜单
	    ,{"id":"100","pid":"2","name":"机构用户","href":"","icon":"icon-nav"}
	    ,{"id":"101","pid":"2","name":"机构用户1","href":"","icon":"icon-nav"}
	    ,{"id":"102","pid":"3","name":"自动生成","href":"","icon":"icon-nav"}
	    ,{"id":"103","pid":"3","name":"自动生成1","href":"","icon":"icon-nav"}
	    ,{"id":"104","pid":"3","name":"自动生成2","href":"","icon":"icon-nav"}
	    //三级菜单
	    ,{"id":"1000","pid":"100","name":"用户管理","href":"${ctx}/adminManage/sys/sysUser/sysUserList.jsp","icon":"icon-nav"}
	    ,{"id":"1001","pid":"100","name":"机构管理","href":"${ctx}/adminManage/sys/sysOffice/list.do","icon":"icon-nav"}
	    
	    ,{"id":"2000","pid":"102","name":"数据库管理","href":"${ctx}/adminManage/auto/autoDb/autoDbList.jsp","icon":"icon-nav"}
	    ,{"id":"2001","pid":"102","name":"数据库表分类","href":"${ctx}/adminManage/auto/autoDbClass/autoDbClassList.jsp","icon":"icon-nav"}
	    ,{"id":"2002","pid":"102","name":"数据库表","href":"${ctx}/adminManage/auto/autoDbTable/autoDbTableList.jsp","icon":"icon-nav"}
	    ,{"id":"2003","pid":"102","name":"数据库表字段","href":"${ctx}/adminManage/auto/autoDbTableField/autoDbTableFieldList.jsp","icon":"icon-nav"}
	];
	
	$(function() {
		var firstId;
		var defActive=" class=\"active\"";
		$.each(menus,function(j,o){
			if(o.pid==1){
				//使用ul来增加头部菜单
				$("#topMenu").append("<li"+defActive+"><a href=\"javascript:void(0)\" onclick=\"showLeftMenu('"+o.id+"')\">"+o.name+"</a></li>");
				if(firstId==null){
					firstId=o.id;
					defActive="";
				}	
			}	
		});
		if(firstId!=null){
			showLeftMenu(firstId);
		}
		// 调整首页frame的高度	
		var height = parseInt($('#mainPanel').height());
		var width = parseInt($('#mainPanel').width());
		$('#tabs').css({
			'height' : height - 3 + 'px',
			'width' : width - 1 + 'px'
		});
	});
	
	function showLeftMenu(id){
		//清空菜单
		var panels = $('#nav').accordion('panels');
		if(panels.length>0){
			var panelsLength=panels.length;
			for(i=panelsLength-1;i>=0;i--){
				var t = panels[i].panel('options').title;
		    	$('#nav').accordion('remove', t);
			}
		}
		//显示菜单
		$.each(menus,function(i,n){
			var selected=true;
			if(n.pid==id){
				var menulist='';
				menulist +='<ul>';
				$.each(menus, function(j, o) {
					if(o.pid==n.id)
						menulist += '<li><div><a ref="'+o.id+'" href="javascript:void(0)" onclick="addTab(\''+o.name+'\',\'' + o.href + '\')" ><span class="icon '+o.icon+'" >&nbsp;</span><span class="nav">' + o.name + '</span></a></div></li> ';
				});
				menulist += '</ul>';
				
				$('#nav').accordion('add', {
		            title: n.name,
		            content: menulist,
		            iconCls: 'icon ' + n.icon
		        });
			}
		});
		//选中第一个
		panels = $('#nav').accordion('panels');
		if(panels.length>0){
			var t = panels[0].panel('options').title;
	    	$('#nav').accordion('select', t);
		}
	}
	
	//添加右侧内容
	function addTab(title, url){
    if ($('#tabs').tabs('exists', title)){
        $('#tabs').tabs('select', title);
    } else {
        var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:99.5%;"></iframe>';
        $('#tabs').tabs('add',{
            title:title,
            content:content,
            closable:true
        });
    }

}
</script>
<style type="text/css">
.logo{
	float: left;
	margin-left: 50px;
}
.logo h1 a{
	display: block;
}
.h_right{
	position:relative;
	float: right;
	margin-right: 10px;
}
.topNav{
	list-style-type:none;
}
.topNav li{
	float:left;/*让li元素左浮动*/
}

.topNav li a{
	width:80px;/*设置元素宽*/
	height:30px;/*设置高度*/
	line-height:30px;/*设置行距，让文字在每行的中间位置*/
	color:#b8b8b8;/*文字颜色*/
	display:block;/*这个比较关键，因为a本身就是联级元素，本身不具有宽高，用这个把它变成块级元素，这样前面设置的宽和高就能起作用了*/
	text-align:center;/*让文本居中*/
	text-decoration:none; /*去掉下划线*/
}
.topNav li.active a,.topNav li a:hover{
	color: #25BEA0;
}
</style>
</head>

<body class="easyui-layout">
<noscript>
<div style=" position:absolute; z-index:100000; height:2046px;top:0px;left:0px; width:100%; background:white; text-align:center;line-height: 20px;color: #fff;">
    <img src="images/noscript.gif" alt='抱歉，请开启脚本支持！' />
</div>
</noscript>
<!-- 头部 -->
<div region="north" border="false" split="true" style="background:#F3F3F3;height: 50px;padding: 1px; overflow: hidden;min-width: 500px">
	<div class="header">
		<div class="logo">
			<h1><a href="index.html"><img src="${ctx}/adminManage/images/logo.png" alt=""/></a></h1>
		</div>
	</div>
	<div class="h_right">
	 <ul id="topMenu" class="topNav">
	 </ul>
	</div> 
</div>
<!-- 底部版本说明 -->
<div region="south" split="true" style="height: 30px; background: #D2E0F2; ">
    <div style="text-align:center;color:#15428B; margin:0px; padding:0px;line-height:23px; font-weight:bold;">By <a href="http://www.shareinfo.com.cn/" target="_blank">深圳协尔</a>(QQ:94300452)</div>
</div>
<!-- 菜单导航 -->
<div region="west" hide="true" split="true" title="导航菜单" style="width:180px;" id="west">
	<div id="nav" class="easyui-accordion" fit="true" border="false">
	<!--  导航内容 -->
		
	</div>
</div>
<!-- 内容显示  -->
<div id="mainPanel" region="center" split="true" style="overflow: hidden">
	<div id="tabs" class="easyui-tabs" fit="true" border="false">
		<div class="easyui-tab" title="欢迎使用" style="padding:2px;overflow:hidden;" >
				<h1 style="font-size:24px;">* 作者：黄鹏 QQ：94300452</h1>
			</div>
	</div>
</div>
</body>
</html>